/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = wtc_mar.h                                         */
/*  NOTE      =                                                    */
/*  DATE      = 2015/08/13 by songbb                               */
/*******************************************************************/

#ifndef __WTC_MAR_H_
#define __WTC_MAR_H_

int wtc_mar_get_float(L7_wtc_packet *p_st_wtc_packet
                    , float *p_f_out);

int wtc_mar_get_double(L7_wtc_packet *p_st_wtc_packet
                    , double *p_d_out);

int wtc_mar_get_mbstring(char *p_codeset_encoding
                        , char *p_data
                        , unsigned int ui_data_len
                        , char **pp_out
                        , unsigned int *p_ui_out_len);

int wtc_mar_roundup4(int i);

int wtc_detect_use_old_protocol_by_string(L7_wtc_packet *p_st_wtc_packet);

int wtc_mar_decode_vector_string(L7_wtc_packet *p_st_wtc_packet
                                , char *p_vector
                                , int i_vector_size
                                , char **pp_out
                                , unsigned int *p_ui_out_len);

int wtc_xdr_length_string(char *p_string
                        , unsigned int ui_string_len);

int wtc_mar_decode_string(L7session_wtc *p_st_wtc_sess
                        , char *p_scratch
                        , int i_scratch_len
                        , L7_wtc_packet *p_st_wtc_packet
                        , char **pp_out
                        , unsigned int *p_ui_out_len);

//////////////////////// for analyze direction
int wtc_remaining(unsigned int ui_payload_len
                , unsigned int *p_ui_offset);

int wtc_skip(char *p_payload
            , unsigned int ui_payload_len
            , unsigned int *p_ui_offset
            , int i_skip_len);

int wtc_get_char(char *p_payload
                , unsigned int ui_payload_len
                , unsigned int *p_ui_offset
                , char *p_c_out);

int wtc_get_int(char *p_payload
                , unsigned int ui_payload_len
                , unsigned int *p_ui_offset
                , unsigned int *p_ui_out);

int wtc_peek_int(char *p_payload
                , unsigned int ui_payload_len
                , unsigned int *p_ui_offset
                , unsigned int *p_ui_out);

int wtc_skip_int(char *p_payload
                , unsigned int ui_payload_len
                , unsigned int *p_ui_offset);

int wtc_skip_float(char *p_payload
                    , unsigned int ui_payload_len
                    , unsigned int *p_ui_offset);

int wtc_skip_double(char *p_payload
                    , unsigned int ui_payload_len
                    , unsigned int *p_ui_offset);

int wtc_skip_string(char *p_payload
                    , unsigned int ui_payload_len
                    , unsigned int *p_ui_offset);

int wtc_mar_decode_string_fad(char *p_payload
                            , unsigned int ui_payload_len
                            , unsigned int *p_ui_offset
                            , char *p_scratch
                            , int i_scratch_len
                            , char **pp_out
                            , unsigned int *p_ui_out_len);

#endif
